		
Uec3.StoreAddWindow = Ext.extend(Ext.app.Module, {
   id: 'store_add',
   getPanel:function(scope) {
		  var store_storeDepartment = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({url : Uec3.App.Constants.homeUrl+'/department/base!findByCompanyId.do'
			}),
			reader : new Ext.data.JsonReader({
				root : 'root',
				fields : [{
					name : 'id'
				}, {
					name : 'name'
					}]
				})
		  });
		var store_comboDepartment = new Ext.form.ComboBox({
			hiddenName : 'departmentId',
			fieldLabel : '部门名称',
			store : store_storeDepartment,
			emptyText : '--请选择--',
			mode : 'local',
			triggerAction : 'all',
			valueField : 'id',
			displayField : 'name',
			loadingText : '加载中...',
			//editable : false
			listeners:{
				'select':function(){
				}
			}
		});
		store_storeDepartment.load();
		var store_ajax = new Ext.data.Connection();
		store_ajax.on('beforerequest',function(){
			Ext.MessageBox.wait("保存数据中...","提示");
		});
		store_ajax.on('requestcomplete',function(){
			Ext.MessageBox.hide();
		});

// 初始化表单对象
		var store_form = new Ext.form.FormPanel({
			labelAlign : 'right',
			labelWidth : 60,
			// title:客户档案,
			frame : true,
			width : 800,
			autoHeight : true,
			buttons:[{
				text:'保存',
				handler: function(){
					if(!store_form.getForm().isValid()){
					   Ext.Msg.alert("提示","表单校验未通过");
		            	return;	
	            	}	
					var formValues =store_form.getForm().getValues(); 
					var jsonAll=Ext.encode(formValues);
					store_ajax.request({
						url:Uec3.App.Constants.homeUrl+'/store/base!save.do',
						params:{jsonAll:jsonAll},
						success: function(res){
							var result=Ext.decode(res.responseText);
							if(result.success=="OK"){
								var store=result.store;
								scope.setLookupValue({"name":store.name,"pyCode":store.companyId,"id":store.id},store_form.ownerCt);
								store_form.ownerCt.close();
							}else{
								Ext.Msg.alert(res.responseText);
							}
						},
						failure:function(res){
							Ext.Msg.alert('失败',res.responseText);
						}
					});
				}
			},{
				text:'取消',
				handler: function(){
					store_form.ownerCt.close();
				}	
			}],
			buttonAlign:'center',
			items : [{
				layout : 'column',
				items : [{
					columnWidth : .5,
					layout : 'form',
					defaultType : 'textfield',
					items : [
						store_comboDepartment
					]},{
					columnWidth : .5,
					layout : 'form',
					defaultType : 'textfield',
					items : [{
						name : 'name',
						fieldLabel : '仓库名称'
						}]
					}]
				}]
		});
	return store_form;
	},
   createWindow : function(params){
   	  var windowId='initial_index';
   	  if(params){
   	  	windowId+=Ext.isEmpty(params.winId)?"":"_"+params.winId;
   	  }
      var desktop = this.app.getDesktop();
      var module=this.app.getModule(this.id);
      var win = desktop.getWindowByUecId(windowId);
      if(!win){
         win = desktop.createWindow({
         	//id:windowId,
            uecId:windowId,
            title: module.launcher.text,
            //closeAction:'hide',
			width:660,
			autoScroll:true,
			autoHeight:true,
			title:'增加仓库-按Esc退出',
			collapsible:true,
			constrait:true,
			modal:true,
			draggable:true,
			plain:true,
			header:true,
            resizable:false,
            layout: "fit", 
            items:[this.getPanel(this)],
            listeners:{
            	'resize':function(win,width,height){
            	}
            }
         });
      } 
  
      win.show();
   }
});
		
		